﻿using SocketServer.SocketAttribute;
using SocketServer.WebSocketAction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestSocektServer.SocketAction
{
    /// <summary>
    /// 日志特性
    /// </summary>
    public class SocketLogAttribute : WebSocketFilterAttribute
    {
        public override void OnActionExecuting(IWebSocketServerAction ServerAction)
        {
            Console.WriteLine("方法执行前:");
            Console.WriteLine(ServerAction.Request.StringMessage);
        }

        public override void OnResultExecuted(IWebSocketServerAction ServerAction)
        {
            Console.WriteLine("方法执行后:");
            Console.WriteLine(ServerAction.Request.ApiPath);
            Console.WriteLine("返回值:");
            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(ServerAction.Result));
        }
    }
}
